home *** CD-ROM | disk | FTP | other *** search
- From: LittleGuyRascal@msn.com (Gregory Saxton)
- Subject: RE: Passing functions as parameters... inconsistent behaviour
- Date: 27 Feb 96 03:01:32 -0800
- References: <4glbau$tge@inet.up.ac.za>
- Message-ID: <00001a81+0000a88d@msn.com>
- Path: news.msn.com!msn.com
- Newsgroups: comp.lang.c++
- Organization: The Microsoft Network (msn.com)
-
- Cool problem.
-
- The reason this is happening has nothing to do with functions as parameters.
-
- The function test is prototyped as type void requiring one parameter
- - a pointer to a function which returns a float - there is no arument
- list specifying int or float so the compiler defaults to a parameter
- of int for passedfunc.
-
- When you change the declaration of function passed to have one
- parameter of type float and not int you are lucky to compile because
- you are multiply defining a function. If this were a C++ application
- the link step would fail with an unresolved external.
-
- Change the prototype of function test to be void test(float
- (*passedfunc)(float) )
- and your are in business!
-
- clear as mud? Good Luck!
-